package jtk.project4.fleet.field;

import java.awt.TextArea;

import nl.coderight.jazz.form.FormLayout;
import nl.coderight.jazz.form.FormLayout.Resize;
import nl.coderight.jazz.form.control.CalendarControl;
import nl.coderight.jazz.form.control.GroupControl;
import nl.coderight.jazz.form.field.ComboField;
import nl.coderight.jazz.form.field.MemoField;
import nl.coderight.jazz.form.field.SpinnerField;
import nl.coderight.jazz.form.field.TextField;
import nl.coderight.jazz.form.field.button.PushButton;

public class PoReceiptByInventoriedPartField extends GroupControl {
	private TextField unitCostField;
	private TextField extendedCostField;
	private TextField nameField;
	private ComboField<String> partNumberField;
	private ComboField<String> PONumberField;
	private ComboField<String> vendorField;
	private SpinnerField<Integer> quantityField;
	private MemoField commentsField;
	private CalendarControl dateField;
	private PushButton dotButton; //mengacu ke add vendor
	
	public PoReceiptByInventoriedPartField(String bindID) {
		// TODO Auto-generated constructor stub
		setTitle("header.POReceiptByInventoriedPartField");
		setBindID(bindID);
		createFields();
		createLayout();
	}
	
	private void createFields(){
		nameField = new TextField("Name",35);
		nameField.setRequired(true);
		
		unitCostField = new TextField("Unit Cost", 15);
		extendedCostField = new TextField("Extended Cost", 15);
		
		partNumberField = new ComboField<String>("Part Number", "Part Number");
		partNumberField.setRequired(true);
		
		PONumberField = new ComboField<String>("PO Number", "PO Number");
		PONumberField.setRequired(true);
		
		vendorField = new ComboField<String>("Vendor", "vendor");
		vendorField.setPreferredSize(nameField.getPreferredSize());
		
		quantityField = new SpinnerField<Integer>("Quantity Used", "Quantity Used");
		
		commentsField = new MemoField();
		commentsField.setRows(3);
		
		dateField = new CalendarControl("Date", 5);
		dateField.setPreferredSize(extendedCostField.getPreferredSize());
		dateField.setRequired(true);
		
		dotButton = new PushButton("...");
	}
	
	private void createLayout() {
		setLayout(new FormLayout())
		.addRow()
		.addLabel("label.partNumber")	.addField(partNumberField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.PONumber")		.addField(PONumberField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.name")			.addField(nameField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.date")			.addField(dateField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.quantity")		.addField(quantityField,Resize.HORIZONTAL)
		.addRow()
		.addLabel("label.unit cost")	.addField(unitCostField)
		.addRow()
		.addLabel("label.extended cost").addField(extendedCostField)
		.addRow()
		.addLabel("label.vendor") .addField(vendorField) .addField(dotButton)
		.addRow()
		.addLabel("label.comments")		.addField(commentsField)
		;
	}
}
